package com.mybills.proj;

import java.util.Calendar;

import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;



public class Set_date extends Activity{
	/** Called when the activity is first created. */
	private TextView mdateDisplay;
	private String mDateDisplay1;
	private String mDateDisplay2;
	private String mDateDisplay3;
	private String mDateDisplay;
    private Button mPickDate;
    private int mYear;
    private int mMonth;
    private int mDay;

    static final int DATE_DIALOG_ID = 0;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.setdate);
        
    	
        //mdateDisplay = (TextView) findViewById(R.id.dateDisplay);
        mPickDate = (Button) findViewById(R.id.pickDate);
        
        
        mPickDate.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                showDialog(DATE_DIALOG_ID);
            }
        });

        // get the current date
        
    }
    private void updateDisplay() {
        mDateDisplay1 = Integer.toString(mMonth+1);
        mDateDisplay2 = Integer.toString(mDay);
        mDateDisplay3 = Integer.toString(mYear);
        setmDateDisplay(mDateDisplay3+"-"+mDateDisplay1+"-"+mDateDisplay2+":"); 
        Intent it = new Intent();
        it.putExtra("picked_date",getmDateDisplay().toString() );
        mdateDisplay = (TextView)findViewById(R.id.resultText); 
    }
    public String getmDateDisplay() {
		return mDateDisplay;
	}
	public void setmDateDisplay(String mDateDisplay) {
		this.mDateDisplay = mDateDisplay;
	}
	private DatePickerDialog.OnDateSetListener mDateSetListener =
        new DatePickerDialog.OnDateSetListener() {

            public void onDateSet(DatePicker view, int year, 
                                  int monthOfYear, int dayOfMonth) {
                mYear = year;
                mMonth = monthOfYear;
                mDay = dayOfMonth;
                updateDisplay();
            }
        };
        @Override
        protected Dialog onCreateDialog(int id) {
            switch (id) {
            case DATE_DIALOG_ID:
                return new DatePickerDialog(this,
                            mDateSetListener,
                            mYear, mMonth, mDay);
            }
            return null;
        }

}
